package com.alm.token.ui.activity;

import android.Manifest;
import android.app.AlertDialog;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.alm.token.ConStant;
import com.alm.token.GlideApp;
import com.alm.token.MyApp;
import com.alm.token.R;
import com.alm.token.base.BaseActivity;
import com.alm.token.ui.data.bean.AddDrawData;
import com.alm.token.ui.data.bean.DrawIndexData;
import com.alm.token.ui.data.bean.RegisterData;
import com.alm.token.ui.data.bean.TransferTransData;
import com.alm.token.ui.data.bean.TurnOutBiTB_QRdata;
import com.alm.token.ui.data.bean.UserWalletData;
import com.alm.token.ui.persenter.MyPreenter;
import com.alm.token.ui.view.TurmOutView;
import com.alm.token.utils.ActionBarHelper;
import com.alm.token.utils.CommonUtil;
import com.alm.token.utils.EmptyUtils;
import com.alm.token.utils.EthWalletUtil;
import com.alm.token.utils.LogUtil;
import com.alm.token.utils.Utils;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.google.gson.Gson;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import baibeiwallet.Constant;
import baibeiwallet.utils.DialogUtils;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.OnFocusChange;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

import static com.alm.token.ui.activity.FundArealistActivity.INTENT_RESULT_CODE_VAULE;
import static com.alm.token.ui.activity.FundArealistActivity.INTENT_RESULT_INTO_CODE;
import static com.alm.token.ui.activity.FundArealistActivity.INTENT_RESULT_NAME_VAULE;
import static com.alm.token.ui.activity.FundArealistActivity.INTENT_RESULT_SUCC_CODE;
import static com.alm.token.ui.persenter.MyPreenter.pay;

//import com.yzq.zxinglibrary.android.CaptureActivity;
//import com.uuzuche.lib_zxing.activity.CaptureActivity;
//import com.uuzuche.lib_zxing.activity.CodeUtils;
//import com.uuzuche.lib_zxing.activity.ZXingLibrary;

public class TurnOutBiTB_FukuanActivity extends BaseActivity implements TextWatcher, TurmOutView<Object> {
    @BindView(R.id.rightItem)
    TextView rightItem;
    @BindView(R.id.img_bizhongicon)
    ImageView imgBizhongicon;
    @BindView(R.id.tv_bizhongtv)
    TextView tvBizhongtv;
    @BindView(R.id.tv_totalmoney)
    TextView tvTotalmoney;
    @BindView(R.id.img_selectbizhong)
    ImageView imgSelectbizhong;
    @BindView(R.id.ly_ooutmoneybizhongtop)
    RelativeLayout lyOoutmoneybizhongtop;
    @BindView(R.id.edt_inputadress)
    TextView edtInputadress;
    @BindView(R.id.img_saoma)
    ImageView imgSaoma;
    @BindView(R.id.edt_inputmoney)
    EditText edtInputmoney;
    @BindView(R.id.tv_bizhongshow)
    TextView tvBizhongshow;
    @BindView(R.id.tv_mathjiaoyifei)
    TextView tvMathjiaoyifei;
    @BindView(R.id.tv_outmoneycommit)
    TextView tvOutmoneycommit;
    @BindView(R.id.tv_msg)
    TextView tvMsg;
    @BindView(R.id.tv_edtleastnumber)
    TextView tvEdtleastNumber;

    private DrawIndexData.DataBean drawIndexDataBean;
    List<DrawIndexData.DataBean.WalletsBean> walletsBeans = new ArrayList<>();
    private double number = 0d, pro = 0d;

    private double totalMOney = 0d;
    private int bizhongType1 = -1, bizhongselect = 0;
    private static final int QRCODE_SCANNER_REQUEST = 1100, VERIFY_REQUEST = 1101;
    private View rootView;
    private double leatNumber = 10.0d;
    private String result = "";
    private TurnOutBiTB_QRdata turnOutBiTB_qRdata;


    @Override
    protected MyPreenter initPreenter() {
        return new MyPreenter(this);
    }

    @Override
    protected int getContentViewId() {
        rootView = LayoutInflater.from(TurnOutBiTB_FukuanActivity.this).inflate(R.layout.activity_turnout_fukuan, null);
        return R.layout.activity_turnout_fukuan;
    }

    @Override
    protected void initVariables() {
        result = getIntent().getStringExtra("scanResult");
        if (EmptyUtils.isNotEmpty(result) && result.indexOf("CollectionPayment") != -1) {
            turnOutBiTB_qRdata = new Gson().fromJson(result, TurnOutBiTB_QRdata.class);
        }
    }

    @Override
    protected void initViews() {
//        new ActionBarHelper(this).setTitle(getString(R.string.app_hint_superegg));
        new ActionBarHelper(this).setTitle(getString(R.string.tv_hint_paytitle));
        edtInputmoney.addTextChangedListener(this);
    }

    @Override
    protected void loadData() {
        preenter.getTransferIndexData();
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ly_ooutmoneybizhongtop:
                showPopwindow();
//                showPopupMenu2(lyOoutmoneybizhongtop);
                break;
            case R.id.tv_outmoneycommit:
                dec1 = new DecimalFormat("0.0000");
                if (number <= 0) {
                    showToast(getString(R.string.alphago_hint_warn5));
                    break;
                }
                if(number<walletsBeans.get(bizhongselect).getMinTransfer()){
                    showToast(getString(R.string.currency_hint1_leastinput,CommonUtil.saveToPoint4WithNo(walletsBeans.get(bizhongselect).getMinTransfer())));
                    break;
                }
//                if (number < leatNumber) {
//                    showToast(getString(R.string.wallet_hint_warn1, CommonUtil.saveToPoint4WithNo(leatNumber)));
//                    break;
//                }
                scanResult = edtInputadress.getText().toString();
                if (scanResult.isEmpty() || !Utils.verifyUserName(scanResult)) {
                    showToast(getString(R.string.profile_hint_warn2));
                    break;
                }
                if (scanResult.length() < 4 || scanResult.length() > 18) {
                    showToast(getString(R.string.profile_hint_warn3));
                    break;
                }
                if (!Utils.verifyUserNameFL(scanResult)) {//[A-Za-z1-9]{2}
                    showToast(getString(R.string.profile_hint_warn4));
                    break;
                }

                if (EmptyUtils.isNotEmpty(MyApp.getUserData()) && EmptyUtils.isNotEmpty(MyApp.getUserData().getData())) {
                    boolean bindMnemonic = MyApp.getUserData().getData().isBindMnemonic();
                    boolean bindGoogleCode = MyApp.getUserData().getData().isBindGoogleCode();
                    boolean payPwd = MyApp.getUserData().getData().isPayPwd();
                    boolean bindEmail = MyApp.getUserData().getData().isBindEmail();
                    if (!payPwd || !bindEmail) {
                        DialogUtils.toBind(this, getSupportFragmentManager(), payPwd, bindEmail, true, true);
                        break;
                    }
                }

                UserWalletData.DataBean.SysMsgBean sysMsgBean = new UserWalletData.DataBean.SysMsgBean();
                sysMsgBean.setTitle(getString(R.string.wallet_hint_warn2));
                sysMsgBean.setContent(getString(R.string.wallet_hint_warn3, CommonUtil.saveToPoint4WithNo(number), tvBizhongshow.getText().toString()));
                DialogUtils.showInfor1(this, sysMsgBean, (pwd) -> {
                    verify();
                });
                break;
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.img_saoma, R.id.rightItem})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rightItem:
                break;
//            case R.id.ly_ooutmoneybizhongtop:
//                showPopupMenu2(lyOoutmoneybizhongtop);
//                break;
            case R.id.img_saoma:
                //扫码
                com.tbruyelle.rxpermissions2.RxPermissions rxPermissions = new com.tbruyelle.rxpermissions2.RxPermissions(TurnOutBiTB_FukuanActivity.this);
                rxPermissions.request(Manifest.permission.CAMERA)
                        .subscribe(new Observer<Boolean>() {
                            @Override
                            public void onSubscribe(Disposable d) {
                            }

                            @Override
                            public void onNext(Boolean granted) {
                                if (granted) {
                                    if (!CommonUtil.isCameraOpen()) {
//                                        ZXingLibrary.initDisplayOpinion(getApplicationContext());
////                                        Intent intent = new Intent(TurnOutBiTB_FukuanActivity.this, CaptureActivity.class);
//                                        Intent intent = new Intent(TurnOutBiTB_FukuanActivity.this, QRCodeScannerActivity.class);
//                                        startActivityForResult(intent, QRCODE_SCANNER_REQUEST);

//                                        Intent intent = new Intent(TurnOutBiTB_FukuanActivity.this, CaptureActivity.class);
////                                        intent.putExtra(com.yzq.zxinglibrary.common.Constant.INTENT_ZXING_CONFIG, MyApp.getZxingConfig());
//                                        startActivityForResult(intent, QRCODE_SCANNER_REQUEST);

                                    } else {
                                        showToast(getString(R.string.profile_hint_item1));
                                    }
                                } else {
                                    Toast.makeText(TurnOutBiTB_FukuanActivity.this, getString(R.string.profile_hint_item2), Toast.LENGTH_SHORT).show();
                                }
                            }

                            @Override
                            public void onError(Throwable e) {
                            }

                            @Override
                            public void onComplete() {
                            }
                        });
                break;
        }
    }

    AlertDialog alert;

    private void verify() {
        alert = DialogUtils.showVerify(this, (pwd, code, googleCode) -> {
            preenter.getTransfertransData(number + "", scanResult, bizhongType1 + "", code, pwd, googleCode);
        }, code1 -> {
            if (MyApp.getUserData() != null && MyApp.getUserData().getData() != null && MyApp.getUserData().getData().getUser() != null) {
                String phone = MyApp.getUserData().getData().getUser().getPhone();
//                preenter.getSmsCodeData(phone, MyPreenter.pay, code1);
                preenter.getSmsCodeData(MyApp.getMail(), pay);
            }
        }, flag -> {
            LogUtil.e("-------------to_TurnOutBiTBActivity");
            startActivityForResult(FundArealistActivity.class, INTENT_RESULT_INTO_CODE);
        });
    }

    String scanResult = "";

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == QRCODE_SCANNER_REQUEST && resultCode == RESULT_OK && data != null) {
//            String result = null;
            String result = data.getStringExtra(com.yzq.zxinglibrary.common.Constant.CODED_CONTENT);
            Log.i("TAG", "扫描结果:" + result);
            if (!TextUtils.isEmpty(result)) {
                if (EthWalletUtil.isETHValidAddress(result)) {
                    scanResult = result;
                    edtInputadress.setText(result.isEmpty() ? "" : result);
                } else {
                    showToast(getString(R.string.wallet_hint_warn));
                }
            } else {
                Toast.makeText(TurnOutBiTB_FukuanActivity.this, getString(R.string.profile_hint_item3), Toast.LENGTH_SHORT).show();
            }
        } else if (requestCode == VERIFY_REQUEST && data != null && data.getExtras() != null) {//说明是转出验证后的结果回来

        } else if (requestCode == INTENT_RESULT_INTO_CODE && resultCode == INTENT_RESULT_SUCC_CODE && data != null) {
            String name = data.getStringExtra(INTENT_RESULT_NAME_VAULE);
            String code = data.getStringExtra(INTENT_RESULT_CODE_VAULE);
            LogUtil.e("name=" + name + "  code=" + code);
            if (alert != null && alert.isShowing()) {
                if (DialogUtils.getTvClickphonecountry() != null) {
                    DialogUtils.getTvClickphonecountry().setText(name);
                }
                if (DialogUtils.getTvSetphonecode() != null) {
                    DialogUtils.getTvSetphonecode().setText(code);
                }
            }
//            tvSetphonecode.setText(code);
//            tvClickphonecountry.setText(name);
        } else {
//            Toast.makeText(TurnOutBiTB_FukuanActivity.this, getString(R.string.profile_hint_item4), Toast.LENGTH_SHORT).show();
//                AppUI.success(getContext(), "解析二维码失败");
        }
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        if (s.toString().contains(".")) {
            if (s.length() - 1 - s.toString().indexOf(".") > 4) {
                s = s.toString().subSequence(0, s.toString().indexOf(".") + 5);
                edtInputmoney.setText(s);
                edtInputmoney.setSelection(s.length());
            }
        }
        if (s.toString().trim().substring(0).equals(".")) {
            s = "0" + s;
            edtInputmoney.setText(s);
            edtInputmoney.setSelection(2);
        }

        if (s.toString().startsWith("0")
                && s.toString().trim().length() > 1) {
            if (!s.toString().substring(1, 2).equals(".")) {
                edtInputmoney.setText(s.subSequence(0, 1));
                edtInputmoney.setSelection(1);
                return;
            }
        }
        number = Double.parseDouble(s != null ? (!s.toString().isEmpty() ? s.toString() : "0") : "0");

        if (bizhongselect < walletsBeans.size() && number > walletsBeans.get(bizhongselect).getMoney()) {
            showToast(getString(R.string.conversioncurrency_hint1_warn6));
        }
    }

    @Override
    public void afterTextChanged(Editable s) {
    }

    double money = 0d;
    DecimalFormat dec1;

    public void mathNumber(double number) {

        if (walletsBeans.get(bizhongselect).getName().equalsIgnoreCase(Constant.G12ContractName)) {//mio
            leatNumber = 10.0d;
            if (walletsBeans.get(bizhongselect).getPrice() != 0 && drawIndexDataBean.getMinDollar() != 0) {
                leatNumber = (drawIndexDataBean.getMinDollar() / walletsBeans.get(bizhongselect).getPrice());
            }
        } else {//! mio
            leatNumber = 0;
        }
//        leatNumber = (drawIndexDataBean.getMinDollar() / walletsBeans.get(bizhongselect).getPrice());
        LogUtil.e("leatNumber1=" + leatNumber);
        BigDecimal b = new BigDecimal(leatNumber);
        leatNumber = b.setScale(4, BigDecimal.ROUND_UP).doubleValue();
        LogUtil.e("leatNumber2=" + leatNumber);
        dec1 = new DecimalFormat("0.0000");
        tvEdtleastNumber.setText(getString(R.string.currency_hint1_leastinput, CommonUtil.saveToPoint4WithNo(leatNumber)));
        money = number * walletsBeans.get(bizhongselect).getPrice();
        dec1 = new DecimalFormat("0.00");

        if (walletsBeans.get(bizhongselect).getTransferSwitch() == 1) {
            tvOutmoneycommit.setBackground(getResources().getDrawable(R.drawable.gradient_btn));
            tvOutmoneycommit.setText(getString(R.string.currency_hint1_extract1));
            tvOutmoneycommit.setOnClickListener(this);
        } else {
            tvOutmoneycommit.setBackground(getResources().getDrawable(R.drawable.gradient_btn_unclick));
            tvOutmoneycommit.setText(getString(R.string.currency_hint1_warn));
            tvOutmoneycommit.setOnClickListener(null);
        }
    }

    public void showPopupMenu2(View view) {
        //参数View 是设置当前菜单显示的相对于View组件位置，具体位置系统会处理
        PopupMenu popupMenu = new PopupMenu(this, view);
        //加载menu布局
        Menu menu = popupMenu.getMenu();
        for (DrawIndexData.DataBean.WalletsBean walletsBean : walletsBeans) {
            menu.add(walletsBean.getName());
        }
        popupMenu.getMenuInflater().inflate(R.menu.menu_popmenu, menu);


        //设置menu中的item点击事件
        popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {

                for (int i = 0; i < walletsBeans.size(); i++) {
                    if (item.getTitle().toString().equalsIgnoreCase(walletsBeans.get(i).getName())) {
                        if (bizhongType1 == walletsBeans.get(i).getId()) {
                            showToast(getString(R.string.crowdfund_hint_warn3));
                            break;
                        }
                        bizhongselect = i;
                        bizhongType1 = walletsBeans.get(i).getId();//0 1 2 3
                        GlideApp.with(TurnOutBiTB_FukuanActivity.this).load(walletsBeans.get(i).getLogo())
                                .listener(new RequestListener<Drawable>() {
                                    @Override
                                    public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                                        return false;
                                    }

                                    @Override
                                    public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
//                                        if (EmptyUtils.isNotEmpty(resource)) {
//                                            CommonUtil. changeSVGColor(TurnOutBiTB_FukuanActivity.this, imgBizhongicon, resource, R.color.black);
//                                            return true;
//                                        }
                                        return false;
                                    }
                                }).error(R.drawable.icon_arctic).into(imgBizhongicon);
                        tvBizhongtv.setText(item.getTitle().toString());
                        tvBizhongshow.setText(item.getTitle().toString());
                        totalMOney = walletsBeans.get(i).getMoney();
                        tvTotalmoney.setText(CommonUtil.saveToPoint4WithNo(totalMOney) + " " + tvBizhongtv.getText().toString());
                        mathNumber(number);
                        break;
                    }
                }
                return true;
            }
        });
        popupMenu.show();
    }


    PopupWindow popWindow;

    private void showPopwindow() {
        View parent = ((ViewGroup) this.findViewById(android.R.id.content)).getChildAt(0);
        View popView = View.inflate(this, R.layout.view_pop_selecter, null);
        LinearLayout ly_pop_body = popView.findViewById(R.id.ly_pop_body);

        if (EmptyUtils.isNotEmpty(walletsBeans)) {
            for (int i = 0; i < walletsBeans.size(); i++) {
                DrawIndexData.DataBean.WalletsBean coinBean = walletsBeans.get(i);

                View itemView = View.inflate(this, R.layout.item_pop_wallet, null);
                GlideApp.with(this)
                        .load(coinBean.getLogo())
                        .error(R.drawable.icon_arctic)
                        .into((ImageView) itemView.findViewById(R.id.img_bizhongicon));
                ((TextView) itemView.findViewById(R.id.name)).setText(coinBean.getName());
                ((TextView) itemView.findViewById(R.id.desc)).setVisibility(View.INVISIBLE);

                ((TextView) itemView.findViewById(R.id.money1)).setText(CommonUtil.saveToPoint4WithNo(coinBean.getMoney()));
                ((TextView) itemView.findViewById(R.id.money2)).setText("1" + coinBean.getName() + "≈" + CommonUtil.saveToPoint2WithNo(coinBean.getPrice()) + "$");

                int finalI = i;
                itemView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        bizhongselect = finalI;
                        bizhongType1 = walletsBeans.get(finalI).getId();//0 1 2 3
                        GlideApp.with(TurnOutBiTB_FukuanActivity.this).load(walletsBeans.get(finalI).getLogo())
                                 .error(R.drawable.icon_arctic).into(imgBizhongicon);
                        tvBizhongtv.setText(walletsBeans.get(finalI).getName());
                        tvBizhongshow.setText(walletsBeans.get(finalI).getName());
                        totalMOney = walletsBeans.get(finalI).getMoney();
                        tvTotalmoney.setText(CommonUtil.saveToPoint4WithNo(totalMOney) + " " + tvBizhongtv.getText().toString());
                        number=0;
                        edtInputmoney.setText("");
                        mathNumber(number);
                        popWindow.dismiss();
                    }
                });
                ly_pop_body.addView(itemView);
            }
            ly_pop_body.setBackgroundColor(getResources().getColor(R.color.text_cccccc));
        }

        RelativeLayout outside = popView.findViewById(R.id.pop_outside);

        int width = getResources().getDisplayMetrics().widthPixels;
        int height = getResources().getDisplayMetrics().heightPixels;

        if (popWindow == null) {
            popWindow = new PopupWindow(popView, width, height);
            popWindow.setAnimationStyle(R.style.BottomToTopAnim);
//        popWindow.setFocusable(true);
            popWindow.setOutsideTouchable(true);// 设置同意在外点击消失
        }
        outside.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popWindow.dismiss();
            }
        });

        ColorDrawable dw = new ColorDrawable(0x30000000);
        popWindow.setBackgroundDrawable(dw);
        popWindow.showAtLocation(parent, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
    }

    @Override
    public void getData(Object o) {

    }

    @Override
    public void jumpToLoginAct(int staue) {
        if (staue == 3) {
//            showToast(getString(R.string.common_relogin));
//            Intent intent = new Intent();
//            intent.setAction(ConStant.EXIT_APP);
//            sendBroadcast(intent);
//            startActivity(BlockWalletLoginActivity.class);
//            finish();
        } else if (staue == 4) {
//            showToast(getString(R.string.paypasw_hint_setpaypsw));
//            Intent intent = new Intent(this,PayPwdActivity.class);
//            intent.putExtra("PayPwdActivityType",PayPwdActivity.PAYPSW_SET);
//            startActivity(intent);
//            finish();
            showToSetPaypswDialog();
        } else if (staue == 666) {
            showToUpdata();
        }
    }

    @Override
    public void onError(String error) {
        showToast(error);
        if (alert != null && alert.isShowing()) {
            alert.dismiss();
        }
    }

    @Override
    public void ShowProgress() {
        showWaitDialog();
    }

    @Override
    public void hideProgress() {
        hideWaitDialog();
    }

    @Override
    public void getDrawIndexData(DrawIndexData drawIndexData) {

    }

    @Override
    public void getAddDrawData(AddDrawData addDrawData) {
        showToast(addDrawData.getMsg());
        if (alert != null && alert.isShowing()) {
            alert.dismiss();
        }
        if (addDrawData.getStatus() == 0) {
            finish();
        }
    }

    @Override
    public void getCode(RegisterData registerData) {
//        if (registerData.getMsg().equalsIgnoreCase(getString(R.string.profile_hint_warn15))) {
//            showToast(getString(R.string.profile_hint_warn14));
//        } else {
//            showToast(registerData.getMsg());
//        }
        showToast(registerData.getMsg());
    }

    @Override
    public void getTransferIndexData(DrawIndexData drawIndexData) {
        if (drawIndexData.getStatus() == 0) {
            drawIndexDataBean = drawIndexData.getData();
            if (drawIndexDataBean != null && drawIndexDataBean.getWallet() != null) {
                walletsBeans = drawIndexDataBean.getWallet();

                if (EmptyUtils.isNotEmpty(turnOutBiTB_qRdata)) {

                    if (walletsBeans.size() < 2) {
                        imgSelectbizhong.setVisibility(View.GONE);
                        lyOoutmoneybizhongtop.setOnClickListener(null);
                    } else {
                        lyOoutmoneybizhongtop.setOnClickListener(this);
                    }

                    if (EmptyUtils.isNotEmpty(turnOutBiTB_qRdata.getCoinId())) {
                        for (int i = 0; i < walletsBeans.size(); i++) {
                            if (String.valueOf(walletsBeans.get(i).getId()).equalsIgnoreCase(turnOutBiTB_qRdata.getCoinId())) {
                                bizhongselect = i;
                                imgSelectbizhong.setVisibility(View.GONE);
                                lyOoutmoneybizhongtop.setOnClickListener(null);
                            }
                        }
                    }

                    edtInputadress.setText(turnOutBiTB_qRdata.getAddress());
                    edtInputadress.setFocusable(false);
                    edtInputadress.setFocusableInTouchMode(false);

                    if (EmptyUtils.isNotEmpty(turnOutBiTB_qRdata.getPrice())) {
                        number = Double.parseDouble(turnOutBiTB_qRdata.getPrice());
                        edtInputmoney.setText(turnOutBiTB_qRdata.getPrice());
                        edtInputmoney.setFocusable(false);
                        edtInputmoney.setFocusableInTouchMode(false);
                    }

                    bizhongType1 = walletsBeans.get(bizhongselect).getId();
                    tvMathjiaoyifei.setText(drawIndexDataBean.getProMoney() + Constant.G12ContractName);
                    tvMsg.setText(TextUtils.isEmpty(drawIndexDataBean.getMsg()) ? "" : drawIndexDataBean.getMsg());
                    GlideApp.with(TurnOutBiTB_FukuanActivity.this).load(walletsBeans.get(bizhongselect).getLogo())
                            .listener(new RequestListener<Drawable>() {
                                @Override
                                public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                                    return false;
                                }

                                @Override
                                public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
//                                    if (EmptyUtils.isNotEmpty(resource)) {
//                                        CommonUtil. changeSVGColor(TurnOutBiTB_FukuanActivity.this, imgBizhongicon, resource, R.color.black);
//                                        return true;
//                                    }
                                    return false;
                                }
                            }).error(R.drawable.icon_arctic).into(imgBizhongicon);
                    totalMOney = walletsBeans.get(bizhongselect).getMoney();
                    tvBizhongtv.setText(walletsBeans.get(bizhongselect).getName());
                    tvBizhongshow.setText(walletsBeans.get(bizhongselect).getName());
                    tvTotalmoney.setText(CommonUtil.saveToPoint4WithNo(totalMOney) + " " + tvBizhongtv.getText().toString());
                    imgSaoma.setVisibility(View.GONE);
                    mathNumber(number);
                }
            } else {
                showToast(drawIndexData.getMsg());
            }
        } else {
            showToast(drawIndexData.getMsg());
        }
    }

    @Override
    public void getTransfertransData(TransferTransData transferTransData) {
        showToast(transferTransData.getMsg());
        if (alert != null && alert.isShowing()) {
            alert.dismiss();
        }
        if (transferTransData.getStatus() == 0) {
            preenter.getTransferIndexData();
        }
    }


    String loginName = "", loginNameOld = "";


    @OnFocusChange(R.id.edt_inputadress)
    void onEdiFocusChange(boolean hasFocus) {

    }

    @OnFocusChange({R.id.edt_inputmoney})
    void onEdiFocusChange(View view, boolean hasFocus) {


    }

    private boolean checkRight = false;

    @Override
    public void getcheckLoginNameData(RegisterData checkLoginNameData) {

    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {

        return super.dispatchTouchEvent(ev);
    }
}
